Micron Document




Java syntax
part 24/46 · 86.7 KB total
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Non-static members of a class define the types of the instance variables and methods, which are related to the objects created from that class. To create these objects, the class must be instantiated by using the new operator and calling the class constructor.

Foo foo = new Foo();

Accessing members

Members of both instances and static classes are accessed with the . (dot) operator.

Accessing an instance member
Instance members can be accessed through the name of a variable.

String foo = "Hello";
String bar = foo.toUpperCase();

Accessing a static class member
Static members are accessed by using the name of the class or any other type. This does not require the creation of a class instance. Static members are declared using the static modifier.

public class Foo {
public static void doSomething() {
}
}
// Calling the static method
Foo.doSomething();

Modifiers

Modifiers are keywords used to modify declarations of types and type members. Most notably there is a sub-group containing the access modifiers.

abstract - Specifies that a class only serves as a base class and cannot be instantiated.
static - Used only for member classes, specifies that the member class does not belong to a specific instance of the containing class.
final - Classes marked as final cannot be extended from and cannot have any subclasses.
strictfp - Specifies that all floating-point operations must be carried out conforming to IEEE 754 and forbids using enhanced precision to store intermediate results.

Abstract class

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────